//用户登录信息保存
var userList = {};

exports.saveUser = function(user){

    var id = user.id;
    userList[id] =user;
};


exports.del = function(id){

     userList[id]=null;
};

exports.get = function(id){
    return userList[id];
};

exports.getAll = function(){
    return userList;
};

exports.freshActiveTime = function(id){

    var user = userList[id];
    if(user){
        user.activeTime = new Date().getTime();
    }
    else{
        console.log("用户不存在");
    }
};

exports.isLogin = function(id){

    var data = userList[id];
   // console.log(userList);
   // console.log(data);
    //存在并且没有超时
    if(data != null  ){
       if( new Date().getTime() - data.activeTime >= 30 * 60 * 1000){
           //超时
           console.info('time out');
            userList[id]=null;
           return false;
       }else{
           return true;
       }
    }
    return false;
};


 